package com.example.pattern.abstractFactory;

/**
 * 应用
 *
 * @author FM_南风
 * @date 2024/6/23
 */
public class AbstractFactoryClient {
 private ProductA productA;
 private ProductB productB;

 public AbstractFactoryClient(AbstractFactory factory) {
  productA = factory.createProductA();
  productB = factory.createProductB();
 }

 public void run() {
  productA.use();
  productB.use();
 }

 public static void main(String[] args) {
  AbstractFactory factoryA = new ConcreteFactoryA();
  AbstractFactoryClient clientA = new AbstractFactoryClient(factoryA);
  clientA.run();

  AbstractFactory factoryB = new ConcreteFactoryB();
  AbstractFactoryClient clientB = new AbstractFactoryClient(factoryB);
  clientB.run();
 }
}
